package com.dxy.hms.socketio.handler;

import com.corundumstudio.socketio.AckRequest;
import com.corundumstudio.socketio.SocketIOClient;
import com.dxy.hms.socketio.Message;
import com.dxy.hms.socketio.OnMessageEventHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class HmsEventMessageHandler implements OnMessageEventHandler<Message> {

    @Override
    public String getEvent() {
        return "test_event";
    }

    @Override
    public Class<Message> getDataClass() {
        return Message.class;
    }

    @Override
    public void onMessage(SocketIOClient socketIOClient, Message data, AckRequest ackRequest) throws Exception {
        log.debug("收到客户端消息：{}", data);
        data.setContent("收到：" + data.getContent());
        socketIOClient.sendEvent("test_event", data);
    }
}
